//copy_constructor.cpp
//3 ways of invoking copy constructor
#include <iostream>
using namespace std;
class Foo
{
public:
  int i;
public:
  Foo(){cout<<"default construtor:Foo()"<<endl; i = 12;}
  Foo(const Foo&){cout<<"copy constructor:Foo(const Foo&)"<<endl;}
  Foo(Foo&){cout<<"copy constructor:Foo(Foo&)"<<endl;}
};

int main(void)
{
  //init
  cout<<"----init_foo----"<<endl;
  Foo init_foo;
  //1st
  cout<<"----foo1----"<<endl;
  Foo foo1(init_foo);
  //2nd
  cout<<"----foo2----"<<endl;
  Foo foo2 = init_foo;
  //3rd
  cout<<"----foo3----"<<endl;
  Foo foo3 = Foo(init_foo);

  //4th
  cout<<"----foo4----"<<endl;
  Foo foo4(); //Do not invoke default constructor; Be treated as a function declaration;
  cout<<"----foo5----"<<endl;
  Foo foo5;cout<<foo5.i<<endl;
  cout<<"----foo6----"<<endl;
  Foo foo6 = Foo();cout<<foo6.i<<endl;
  
  //Error!
  // Foo foo5 = Foo; 

  return 0;
}
